﻿using InventoryManagementSystem.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InventoryManagementSystem.DataModel
{
    public class Product : BindableBase
    {
        private Guid id = Guid.Empty;
        public Guid Id
        {
            get
            {
                return id;
            }
            set
            {
                SetProperty(ref id, value);
            }
        }

        private string barCode = string.Empty;
        public string BarCode
        {
            get
            {
                return barCode;
            }
            set
            {
                SetProperty(ref barCode, value);
            }
        }

        private string name = string.Empty;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                SetProperty(ref name, value);
            }
        }

        private decimal unitPrice;
        public decimal UnitPrice
        {
            get
            {
                return unitPrice;
            }
            set
            {
                SetProperty(ref unitPrice, value);
            }
        }

        private decimal count;
        public decimal Count
        {
            get
            {
                return count;
            }
            set
            {
                SetProperty(ref count, value);
            }
        }

        public void Reset()
        {
            Id = Guid.Empty;
            BarCode = string.Empty;
            Name = string.Empty;
            UnitPrice = 0;
            Count = 0;
        }

        public Product Clone()
        {
            var product = new Product();
            product.Id = Id;
            product.BarCode = BarCode;
            product.Name = Name;
            product.UnitPrice = UnitPrice;
            product.Count = Count;
            return product;
        }

        public bool Validate()
        {
            return !string.IsNullOrWhiteSpace(BarCode) &&
                BarCode.Length == 13 &&
                !string.IsNullOrWhiteSpace(Name) &&
                UnitPrice > 0;
        }
    }
}
